package com.yanqu.road.server.manger.zhaoshang;

import com.yanqu.road.entity.config.zhaoshang.ZsProjectInfo;
import com.yanqu.road.logic.bussiness.zhaoshang.ZhaoShangBussiness;
import com.yanqu.road.logic.config.GameConfig;
import com.yanqu.road.server.TempMgr;

import java.util.Map;

public class ZsConfigMgr extends TempMgr {

    //configId
    private static Map<Integer, ZsProjectInfo> zsProjectInfoMap;

    @Override
    public boolean reloadConfig() throws Exception {
        zsProjectInfoMap = ZhaoShangBussiness.getZsProjectInfo();
        return true;
    }

    @Override
    public boolean reloadData() throws Exception {
        return true;
    }

    @Override
    public boolean init() throws Exception {
        return reload();
    }

    @Override
    public boolean stop() {
        return false;
    }

    public static Map<Integer, ZsProjectInfo> getZsProjectInfoMap() {
        return zsProjectInfoMap;
    }

    public static ZsProjectInfo getByType(int type) {
        for (ZsProjectInfo projectInfo : zsProjectInfoMap.values()) {
            if (projectInfo.getType() == type) {
                return projectInfo;
            }
        }
        return null;
    }

    public static int getZsListSize() {
        return GameConfig.ZS_PROJECT_LIST_SIZE_LIMIT < 1000 ? 1000 : GameConfig.ZS_PROJECT_LIST_SIZE_LIMIT;
    }

}
